library(ggplot2)


#####
# Figure 1
# Effect for main DVs for entire sample
# Main effects 
#####
t <- read.csv("~/Data/Post estimation data/main effects.csv")

t$variable <- reorder(t$variable,t$item.order)
t$party <- reorder(t$party,t$party.order)
dodge<-position_dodge(width=.33)

my.labels <- c("Descriptive norm",#2
"Injunctive norm",#3
"Descriptive +\ninjunctive norm")#4 

dev.new(width=7,height=3.5)
dev.size()	


ggplot(t, aes(x= b, y=condition)) +
	geom_vline(xintercept = 0,linetype="solid",color="black",size=.5) +
	geom_pointrange(aes(xmin=lower, xmax=upper, shape=party,color=party,fill=party),fatten = 2,size=.33,position=dodge) + 
	scale_color_manual(values=c("black")) + 
	scale_fill_manual(values=c("black")) + 
	scale_shape_manual(values=c(21)) + 
    scale_y_continuous(expand = c(0.05, 0.05) , breaks=c(2,3,4), labels= my.labels) +
	ylab(" ") + xlab("Difference") + 
	theme_linedraw() +
		theme(aspect=1)+
		facet_wrap(~variable , ncol=2)+ 
		theme(panel.border = element_rect(fill=NA, colour = "black", size=.6)) +
	    theme(strip.background = element_rect(color="black",fill="grey90",size=.6)) + 
	  	theme(strip.text = element_text(color = 'black')) + 			
	  	theme(panel.grid.minor = element_blank()) +
	  	theme(axis.ticks.y = element_blank()) +
		theme(legend.title = element_blank()) + 	
		theme(panel.grid.major = element_line(colour = "grey90",size=0.4, linetype="solid")) +
		theme(legend.position = "none")

#####
# Figure 2
# Effect all four DVs by party
#####
t <- read.csv("~/Data/Post estimation data/effect by party.csv")

t$variable <- reorder(t$variable,t$item.order)
t$party <- reorder(t$party,t$party.order)
dodge<-position_dodge(width=.33)

my.labels <- c("Descriptive norm",#2
"Injunctive norm",#3
"Descriptive +\ninjunctive norm")#4 

dev.new(width=6,height=3.667)
dev.size()	

ggplot(t, aes(x= b, y=condition,group= party)) +
	geom_vline(xintercept = 0,linetype="solid",color="black",size=.5) +
	geom_pointrange(aes(xmin=lower, xmax=upper, shape=party,color=party,fill=party),fatten = 2,size=.33,position=dodge) + 
	scale_color_manual(values=c("blue", "purple", "red")) + 
	scale_fill_manual(values=c("blue", "purple", "red")) + 
	scale_shape_manual(values=c(24, 22,23)) + 
    scale_y_continuous(expand = c(0.05, 0.05) , breaks=c(2,3,4), labels= my.labels) +
	ylab(" ") + xlab("Difference") + 
	theme_linedraw() +
		theme(aspect=1)+
		facet_wrap(~variable)+ 
		theme(panel.border = element_rect(fill=NA, colour = "black", size=.6)) +
	    theme(strip.background = element_rect(color="black",fill="grey90",size=.6)) + 
	  	theme(strip.text = element_text(color = 'black')) + 			
	  	theme(panel.grid.minor = element_blank()) +
	  	theme(axis.ticks.y = element_blank()) +
		theme(legend.title = element_blank()) + 	
		theme(panel.grid.major = element_line(colour = "grey90",size=0.4, linetype="solid"))	

#####
# Figure 3
# Effect for main DVs for entire sex and party
#####
s <- read.csv("~/Data/Post estimation data/sex and party.csv")

s$variable <- reorder(s$variable,s$item.order)
dodge<-position_dodge(width=.5)

my.labels <- c("Descriptive norm",#2
"Injunctive norm",#3
"Descriptive +\ninjunctive norm")#4 

dev.new(width=7,height=3.5)
dev.size()	

ggplot(s, aes(x= b, y=condition,group= category)) +
	geom_vline(xintercept = 0,linetype="solid",color="black",size=.5) +
	geom_pointrange(aes(xmin=lower, xmax=upper, shape= category,color=category,fill=category),fatten = 2,size=.33,position=dodge) + 
	scale_color_manual(values=c("blue", "blue", "purple", "purple", "red", "red")) + 
	scale_fill_manual(values=c("blue", "blue", "purple", "purple", "red", "red")) + 
	scale_shape_manual(values=c(21, 22,21,22, 21, 22)) + 
    scale_y_continuous(expand = c(0.05, 0.05) , breaks=c(2,3,4), labels= my.labels) +
	ylab(" ") + xlab("Difference") + 
	theme_linedraw() +
		theme(aspect=1)+
		facet_wrap(~variable)+ 
		theme(panel.border = element_rect(fill=NA, colour = "black", size=.6)) +
	    theme(strip.background = element_rect(color="black",fill="grey90",size=.6)) + 
	  	theme(strip.text = element_text(color = 'black')) + 			
	  	theme(panel.grid.minor = element_blank()) +
	  	theme(axis.ticks.y = element_blank()) +
		theme(legend.title = element_blank()) + 	
		theme(panel.grid.major = element_line(colour = "grey90",size=0.4, linetype="solid"))
		